﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Input;

namespace CaptchaLearning
{
    public abstract class WorkspaceViewModel : ViewModelBase
    {
        #region Fields

        DelegateCommand _closeCommand;

        #endregion // Fields

        #region Constructor

        protected WorkspaceViewModel()
        {
        }

        #endregion // Constructor

        #region CloseCommand

        /// <summary>
        /// Description: Trả về command remove workspace này khỏi UI
        /// Created by: Nam Mai
        /// Create date : 10/6/2012
        /// </summary>
        public ICommand CloseCommand
        {
            get
            {
                if (_closeCommand == null)
                    _closeCommand = new DelegateCommand(new Action(OnRequestClose),
                        () => true);

                return _closeCommand;
            }
        }

        #endregion // CloseCommand

        #region RequestClose [event]

        /// <summary>
        /// Description: Raised khi workspace này remove form UI
        /// Created by: Nam Mai
        /// Created date: 10/6/2012
        /// </summary>
        public event EventHandler RequestClose;

        protected void OnRequestClose()
        {
            EventHandler handler = this.RequestClose;
            if (handler != null)
                handler(this, EventArgs.Empty);
        }

        #endregion // RequestClose [event]
    }
}
